import 'package:flutter/cupertino.dart';
import 'package:flutter_09_game/config/app_color.dart';
import 'package:flutter_09_game/config/app_routes.dart';
import 'package:flutter_09_game/generated/assets.dart';
import 'package:flutter_09_game/generated/locales.g.dart';
import 'package:flutter_09_game/user/app_user_manager.dart';
import 'package:flutter_09_game/widgets/image/auto_image.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

class PromotionTransferBing extends StatelessWidget {
  const PromotionTransferBing({super.key});

  @override
  Widget build(BuildContext context) {
    return Obx(() {
      return Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          // Text(L)
          // 32.verticalSpaceFromWidth,
          RichText(
              text: TextSpan(children: [
            TextSpan(
              text: LocaleKeys.usdtWithdrawSecurityTips.tr,
              style: TextStyle(
                  color: AppColor.textPrimary.withOpacity(0.94),
                  fontSize: 14.sp,
                  fontWeight: FontWeight.w600),
            ),
            TextSpan(
              text:
                  "${AppUserManager().user.value?.hasSetFundPassword != true ? LocaleKeys.fundPassword.tr : ''}${AppUserManager().user.value?.hasSetFundPassword != true && AppUserManager().user.value?.hasBindTrc20Address != true ? '、' : ''}${AppUserManager().user.value?.hasBindTrc20Address != true ? LocaleKeys.betAddress.tr : ''}",
              style: TextStyle(
                  color: AppColor.primary,
                  fontSize: 14.sp,
                  fontWeight: FontWeight.w600),
            )
          ])),

          21.verticalSpaceFromWidth,
          Visibility(
              visible: AppUserManager().user.value?.hasSetFundPassword != true,
              child: _buildSafeItem(
                  Assets.promotionLock, LocaleKeys.fundPassword.tr,
                  onClick: () {
                Get.toNamed(AppRoutes.profileSetPasswordPage);
              })),


          Visibility(
              visible: AppUserManager().user.value?.hasBindTrc20Address != true,
              child: _buildSafeItem(
                  Assets.promotionAddress, LocaleKeys.betAddress.tr, onClick: () {
                if (AppUserManager().user.value?.hasSetFundPassword != true) {
                  Get.toNamed(AppRoutes.profileSetPasswordPage);
                } else {
                  Get.toNamed(AppRoutes.profileBindAddressPage);
                }
              }))
        ],
      );
    });
  }

  Widget _buildSafeItem(String iconPath, String title,
      {required Function onClick}) {
    return GestureDetector(
      onTap: () {
        onClick.call();
      },
      child: Container(
        margin: EdgeInsets.only(bottom: 16.w),
        padding: EdgeInsets.all(12.w),
        decoration: BoxDecoration(
          color: AppColor.homeTabBackground,
          borderRadius: BorderRadius.circular(12.w),
        ),
        child: Row(
          children: [
            AutoImage(
              iconPath,
              width: 44.w,
            ),
            14.horizontalSpace,
            Expanded(
                child: Text(
              title,
              style: TextStyle(
                  color: AppColor.textPrimary.withOpacity(0.94),
                  fontSize: 14.sp,
                  fontWeight: FontWeight.w600),
            )),
            14.horizontalSpace,
            AutoImage(
              Assets.gameArrowRight,
              width: 16.w,
            )
          ],
        ),
      ),
    );
  }
}
